﻿using System;
using System.Text;
using System.Linq;
using System.Linq.Expressions;
using System.Text.Json;
using System.Diagnostics;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Reflection;
using System.Data.Common;
using Fast.Framework.Interfaces;
using Fast.Framework.Extensions;
using Fast.Framework.Models;
using Oracle.ManagedDataAccess.Client;
using MySqlConnector;
using Npgsql;
using System.Data.SQLite;
using System.Data.SqlClient;
using System.ComponentModel.DataAnnotations;
using Fast.Framework.Utils;

namespace Fast.Framework.Test
{
    public class Program
    {
        static async Task Main(string[] args)
        {
            try
            {
                IDbContext db = new DbContext(new List<DbOptions>()
                {
                    new DbOptions()
                    {
                        DbId="0",
                        DbType=DbType.SQLServer,
                        ProviderName="System.Data.SqlClient",
                        FactoryName="System.Data.SqlClient.SqlClientFactory,System.Data",
                        ConnectionStrings="server=localhost;database=Test;user=sa;pwd=123456789;min pool size=3;max pool size=100;connect timeout=30;"
                    },
                    new DbOptions()
                    {
                        DbId="1",
                        DbType=DbType.MySQL,
                        ProviderName="MySqlConnector",
                        FactoryName="MySqlConnector.MySqlConnectorFactory,MySqlConnector",
                        ConnectionStrings="server=localhost;database=Test;user=root;pwd=123456789;port=3306;min pool size=3;max pool size=100;connect timeout=30;"}
                });//数据库上下文

                db.Aop.DbLog = (sql, parameters) =>
                {
                    Console.WriteLine(sql);
                    if (parameters != null)
                    {
                        foreach (var item in parameters)
                        {
                            Console.WriteLine($"参数名:{item.ParameterName} 参数值:{item.Value}");
                        }
                    }
                };

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.ReadKey();
        }
    }

    public class BoolTest
    {
        public bool IsOk { get; set; }
    }
}